my_str = "itheima and itcast"
value = my_str[8]
value2 = my_str[-8]
print(value)
print(value2)


# index方法
my_str.index("and")
print(my_str.index("and"))

# replace方法
new_my_str = my_str.replace("it","程序")
print(f"将字符串{my_str}进行替换后得到{new_my_str}")

# split方法
my_str_list = my_str.split(" ")
print(my_str_list)

# strip方法
my_str = "  itheima and itcast  "
new_my_str = my_str.strip()
print(f"{my_str}被strip后,结果:{new_my_str}")

my_str = "12itheima and itcast21"
new_my_str = my_str.strip("12")
print(f"{my_str}被strip后,结果:{new_my_str}")

# count方法
my_str = "itheima and itcast"
count = my_str.count("it")
print(f"字符串{my_str}中it出现的次数是{count}")

# len()
num = len(my_str)
print(f"字符串{my_str}的长度是{num}")

my_str = "黑马程序员"
index = 0
while index < len(my_str):
    print(my_str[index])
    index += 1

my_str = "黑马程序员"
for i in my_str:
    print(i)
